import { BROADCAST_TYPE_LIST, BROADCAST_TYPE } from '@/const/type';
export const tableOption = () => {
  return {
    ...window.$crudMixins.tableOptions,
    addBtn: false,
    editBtn: false,
    delBtn: false,
    menuWidth: 260,
    searchLabelWidth: 120,
    emptyBtn: false,
    submitBtn: false,
    group: [
      {
        label: '宠物信息',
        prop: 'group2',
        column: [
          {
            label: '宠物编号',
            prop: 'code',
            detail: true,
          },
          {
            label: '宠物昵称',
            prop: 'nickName',
            detail: true,
          },
          {
            label: '宠物性别',
            detail: true,
            prop: 'gender',
            type: 'select',
            dicUrl: '/admin/dict/type/pet_sex',
          },
        ],
      },
      {
        label: '宠物记录',
        prop: 'group1',
        column: [
          {
            label: '记录类型',
            prop: 'type',
            type: 'select',
            rules: [
              {
                required: true,
                message: '请选择记录类型',
              },
            ],
            dicData: [
              {
                label: '随手记',
                value: '1',
              },
              {
                label: '绝育',
                value: '2',
              },
              {
                label: '疫苗',
                value: '3',
              },
              {
                label: '驱虫',
                value: '4',
              },
              {
                label: '洗澡',
                value: '5',
              },
              {
                label: '体检',
                value: '6',
              },
              {
                label: '称体重',
                value: '7',
              },
            ],
          },
          {
            label: '记录时间',
            prop: 'recordTime',
            type: 'datetime',
            format: 'yyyy-MM-dd HH:mm:ss',
            valueFormat: 'yyyy-MM-dd HH:mm:ss',
            // value: new Date(),
            rules: [
              {
                required: true,
                message: '请选择记录时间',
              },
            ],
          },
          {
            label: '记录类型',
            prop: 'fileType',
            type: 'radio',
            row: true,
            span: 12,
            dicData: BROADCAST_TYPE_LIST,
            rules: [
              {
                required: true,
                message: '请选择记录类型',
              },
            ],
            control: (val, form) => {
              if (val === BROADCAST_TYPE.PICTURE) {
                return {
                  petPicture: {
                    display: true,
                  },
                  petVideo: {
                    display: false,
                  },
                };
              } else {
                return {
                  petPicture: {
                    display: false,
                  },
                  petVideo: {
                    display: true,
                  },
                };
              }
            },
          },
          {
            label: '',
            display: true,
            prop: 'petPicture',
            type: 'upload',
            // listType: 'picture-img',
            listType: 'picture-card',
            fileSize: 10 * 1024,
            fileType: 'img', //img/video/audio
            propsHttp: {
              name: 'hash',
              url: 'key',
            },
            multiple: true,
            // action: 'http://upload-z2.qiniup.com',
            oss: 'qiniu',
            cropperOption: {
              enlarge: 2,
              fixed: true,
              fixedNumber: [0.75, 1],
            },
            tip: '请上传jpg/png/jpeg/webp/heic类型的文件，且大小不超过10M，最多可上传9张图片',
            row: true,
            span: 24,
            limit: 9,
            accept: '.jpg,.png,.jpeg,.webp,.heic',
            rules: [
              {
                required: true,
                message: '请上传图片',
              },
            ],
          },
          {
            label: '',
            prop: 'petVideo',
            type: 'upload',
            fileSize: 50 * 1024,
            // listType: 'picture-card',
            listType: 'picture-img',
            fileType: 'video', //img/video/audio
            propsHttp: {
              name: 'hash',
              url: 'key',
            },
            // action: 'http://upload-z2.qiniup.com',
            oss: 'qiniu',
            tip: '视频时长仅支持3分钟以内，建议优先9-30秒，最多可上传1个视频',
            row: true,
            span: 24,
            accept: '.mp4',
            limit: 1,
            rules: [
              {
                required: true,
                message: '请上传视频',
              },
            ],
          },
          {
            type: 'textarea',
            label: '记录内容',
            prop: 'content',
            span: 24,
            rules: [
              {
                required: true,
                message: '请输入记录内容',
              },
            ],
            showWordLimit: true,
            maxlength: 500,
          },
        ],
      },
    ],
  };
};
